package cn.tedu.mintmall.controller;

import cn.tedu.mintmall.dto.AdminLoginDTO;
import cn.tedu.mintmall.restful.JsonResult;
import cn.tedu.mintmall.service.IPassportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/admins", produces = "application/json; charset=utf-8")
public class PassportController {

    @Autowired
    private  IPassportService passportService;

    // 以下是测试访问的请求
    @GetMapping("/hello")
    public String sayHello() {
        return "hello~~~";
    }

    // http://localhost:8080/admins/login?username=root&password=123456
    @PostMapping("/login")
    public JsonResult<String> login(AdminLoginDTO adminLoginDTO) {
        String jwt = passportService.login(adminLoginDTO);
        return JsonResult.ok(jwt);
    }

}
